var CONST_FAIL_LOG = "SFAIL_LOG";
function haveDataDetail(){
	
	/* Hide/Show search condition.*/
	var repName = frmreport.repName.value;	
	if (repName != "dummy"){
		if (repName == CONST_FAIL_LOG ){ // for report log system.
			HideObject("showSearchCond");
			HideObject("hideSearchCond");
			ShowObject("showLogCond");			
		}else{
			HideObject("hideSearchCond");
			HideObject("showLogCond");
			ShowObject("showSearchCond");			
		}
		disButton(false);
	} else{		
		disButton(true);	
	}
	
}
	
function HideObject(id) {
	if(id.length < 1) { 
		return; 
	}
	document.getElementById(id).style.display = "none";	
}

function ShowObject(id) {
	if(id.length < 1) { 
		return; 
	}
	document.getElementById(id).style.display = "block";
}

function disButton(flag){
	
	document.getElementById("btnPreview").disabled = flag;
	document.getElementById("btnPrint").disabled = flag;
	document.getElementById("btnExcel").disabled = flag;	
}

function clearConditionValue(){
	frmreport.rdateFrom.value = "";
	frmreport.rdateTo.value = "";	
	frmreport.ibcCode.value = "";
	frmreport.rdealId.value = "";
	frmreport.custName.value = "";	
	frmreport.tradName.value = "";
	frmreport.prxGroup.value = "";
	frmreport.prxName.value = "";
	frmreport.costcenter.value = "";
	
	/* For report log system */
	frmreport.logdateFrom.value = ""; 
	frmreport.logdateTo.value = "";
	frmreport.ldateFrom.value = "";
	frmreport.ldateTo.value = "";
	frmreport.system.value = "";
	frmreport.service.value = "";
	frmreport.ldealId.value = "";
	frmreport.srcRef.value = "";
	frmreport.costId.value = "";
}

function clearErrorStyle(){
	frmreport.rdateFrom.removeAttribute("style");
	frmreport.rdateTo.removeAttribute("style");
	frmreport.ibcCode.removeAttribute("style");
	frmreport.rdealId.removeAttribute("style");
	frmreport.custName.removeAttribute("style");
	frmreport.tradName.removeAttribute("style");
	frmreport.prxGroup.removeAttribute("style");
	frmreport.prxName.removeAttribute("style");
	frmreport.costcenter.removeAttribute("style");
	
	
	// For report log system
	frmreport.logdateFrom.removeAttribute("style");
	frmreport.logdateTo.removeAttribute("style");
	frmreport.ldateFrom.removeAttribute("style");
	frmreport.ldateTo.removeAttribute("style");
	frmreport.system.removeAttribute("style");
	frmreport.service.removeAttribute("style");
	frmreport.ldealId.removeAttribute("style");
	frmreport.srcRef.removeAttribute("style");
	frmreport.costId.removeAttribute("style");
}

function onChangeReportType(){
	var repName = frmreport.repName.value;		
	clearConditionValue();		

	if (repName == "dummy"){
		clearErrorStyle();
		HideObject("showSearchCond");
		HideObject("showLogCond");		
		ShowObject("hideSearchCond");
		disButton(true);	
		
	}  else {
		clearErrorStyle();
		if (repName == CONST_FAIL_LOG){  // for report log system.
			HideObject("hideSearchCond");
			HideObject("showSearchCond");
			ShowObject("showLogCond");
		}else{
			HideObject("hideSearchCond");
			HideObject("showLogCond");
			ShowObject("showSearchCond");
		}	
		disButton(false);
	} 
	
	
	if ($("#result").find("tr").size() > 1) {
		HideObject("griddetail");
		HideObject("pager");
	}
	
}


